﻿$(function () {
    for (var i = 0; i < d.length; i++) {
        $('#datas').append('<div class="aui-Address-box"><div class="aui-Address-box-item"><div class="aui-Address-box-item-bd"><p>' + d[i].name + '</p></div><div class="aui-Address-box-item-ft"><p>' + d[i].phone + '</p></div></div><div class="aui-Address-box-item"><div class="aui-Address-box-item-bd"><p>' + d[i].provincename + d[i].cityname + d[i].addressinfo + '</p></div></div><div class="aui-Address-box-item"><div class="aui-Address-box-item-bd"><p onclick="setdefault(' + i + ')"><input type="checkbox" class="check goods-check goodsCheck"' + (d[i].isdefault == 1 ? ' checked="checked"' : '') + ' style="background-size: 17px 17px;"> <em style="padding-left:24px;">默认地址</em></p></div><div class="aui-Address-box-item-ft"><a href="javascript:;" onclick="del(' + i + ')">删除</a></div></div></div>');
    }
});
function setdefault(n) {
    loading();
    $.post('/dos_m/address_setdefault', { code: d[n].code }, function (d) { eval(d); });
}
function sel(n) {
    location.href = '/shop/add_order?addresscode=' + d[n].code;
}
function del(n) {
    layer.open({
        content: '确认删除？'
    , btn: ['删除', '取消']
    , skin: 'footer'
    , yes: function (index) {
        layer.closeAll();
        loading();
        $.post('/dos_m/address_del', { code: d[n].code }, function (d) { eval(d); });
    }
    });
}
function ok() {
    location.href = location.href;
}